package com.example.a623

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_internet.*

class Internet : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_internet)

        var sp=getSharedPreferences("data", MODE_PRIVATE)
        edit_adress.setText(sp.getString("adress",""))
        edit_port.setText(sp.getString("port",""))


        save_btn.setOnClickListener {

            var adress=edit_adress.text.toString()
            var port=edit_port.text.toString()
            if (adress.equals("")||port.equals(""))
            {
                Toast.makeText(applicationContext,"请输入服务器地址与端口号！",Toast.LENGTH_SHORT).show()
            }
            else{
                var editor=sp.edit()
                editor.putString("adress",adress)
                editor.putString("port",port)
                editor.commit()

                startActivity(Intent(applicationContext,Login::class.java))
            }


        }
    }
}